<?php
/*
 Primary Author: Derek Shue
Secondary: Alex Arey
Documentation: Cheng Yi
Updated: 12/10/2011
Module Description: The Course Association form is used by an administrator to associate a volunteer request with a course.
*/

class Application_Form_CourseAssociation extends Zend_Form {

	private $courses;
	private $volunteerrequests;



	public function __construct(array $params = array()) {
		$this->courses = $params['courses'];
		$this->volunteerrequests = $params['VRs'];
		parent::__construct();
	}

	public function init(){
		$this->setMethod('post');

		$courseoptions = array();
		$volunteerrequestoptions = array();
		$volunteerquery = new Application_Model_VolunteerQuery();

		if($this->courses)
		foreach($this->courses as $course){
			$courseoptions[$course['CID']] = $course['DEPARTMENT'].$course['COURSENUMBER'];
		}

		if($this->volunteerrequests)
		foreach($this->volunteerrequests as $volunteerrequest){
			$volunteerrequestoptions[$volunteerrequest['VRID']] = $volunteerquery->getPartnerNameForVRID($volunteerrequest['VRID']).' - '.$volunteerrequest['POSITIONTITLE'] ;
		}
		/*
		 The form dynamically displays the available Volunteer Requests that can be associated with a Course.
		*/
		$this->addElement('radio','RID',array('label'=>'Volunteer Request:','multiOptions'=> $volunteerrequestoptions,'required'=>true));
		/*
		 The form dynamically displays the available Courses that can be associated with a Volunteer Request.
		*/
		$this->addElement('radio','CID',array('label'=>'Course:','multiOptions'=> $courseoptions, 'required'=>true));
		$this->addElement('text','NUMPOSITIONS',array('label'=>'Positions Granted:','required'=>true));

		$this->addElement('submit','submit',array('label'=>'Submit Request'));
	}
}
?>
